Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add teardown phase to doctests #2577

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lgoettgens
Copy link

Resolves #2058, resolves #2566.

This PR introduces the doc meta key DocTestTeardown and the jldoctest kwarg teardown, both of which contain code code that gets executed after the doctest itself. (after every block, let's keep the discussion about how to handle multiple same-named blocks in #2567).
If the Documenter maintainers (@mortenpi @fredrikekre ) still like this, I'll continue with adding this new feature to the documentation and add some tests.

My current only idea for testing is to add some print statements as teardown code and then compare the output, similar to the existing doctest tests in

run_makedocs(["working.md"]) do result, success, backtrace, output
. In case of other ideas here please let me know.

cc @maleadt @fingolfin

@fingolfin
Copy link
Contributor

Awesome, thank you!

For testing, you could also modify some global variable and observe the side effect? E.g. have a global counter that is incremented in setup and decrement in teardown and verify it is zero at the end, or something like that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DocTestTeardown for cleaning-up the DocTestSetup state (or similar feature) Block-level teardown code
2 participants